
def func():
    i = 0
    while i < 5:
        tmp = yield i
        print("tmp:", tmp)
        for x in range(tmp + 1):
            print("*" * x)
        i+=1
    return "没有数据了"

g = func()
print(g)
# print(next(g))
# print(g.__next__())
# print(next(g))
# print(next(g))
# print(next(g))
# print(next(g))

n1 = g.send(None)
n2 = g.send(3)
n3 = g.send(5)
print(n1, n2, n3)

"""
 生成器方法
    __next__（） 获取下一个元素
    
    send(value) 向每次生成器调用中传值，注意：第一次调用需要send(None)   

"""
